#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void boundfill(int x,int y,int b,int f);
void main()
{
	int gd=DETECT,gm,i;
	clrscr();
	initgraph(&gd,&gm,"C:\\TC\\BGI");
	rectangle(0,0,getmaxx(),getmaxy());
     //	setcolor(WHITE);
	rectangle(30,100,40,400);
	boundfill(35,300,WHITE,BLUE);
//	floodfill(35,120,BROWN);
//	setcolor(BROWN);
	for(i=0;i<=10;i++)
	{

		rectangle(0,0,getmaxx(),getmaxy());
     //	setcolor(WHITE);
	rectangle(30,100,40,400);
	boundfill(35,300,WHITE,BLUE);
	       if(i%2==0){
	rectangle(40,100,150,124);
	boundfill(100,120,WHITE,BROWN);
//	setcolor(WHITE);
	rectangle(40,124,150,148);
	boundfill(100,130,WHITE,WHITE);
//	setcolor(GREEN);
	rectangle(40,148,150,172);
	boundfill(100,150,WHITE,GREEN);
	setcolor(BLUE);
	circle(95,136,12);
	boundfill(95,136,BLUE,BLUE);
	setcolor(WHITE);
	line(95,124,95,148);
	line(83,136,107,136);
}
	else{

	  rectangle(40,100,155,124);
	boundfill(100,120,WHITE,BROWN);
//	setcolor(WHITE);
	rectangle(40,124,155,148);
	boundfill(100,130,WHITE,WHITE);
//	setcolor(GREEN);
	rectangle(40,148,155,172);
	boundfill(100,150,WHITE,GREEN);
	setcolor(BLUE);
	circle(98,136,12);
	boundfill(98,136,BLUE,BLUE);
	setcolor(WHITE);
	line(98,124,95,148);
	line(83,136,107,136);
	}
	delay(150);
	}
	rectangle(30,100,40,400);
	boundfill(35,300,WHITE,BLUE);
	getch();
}
void boundfill(int x,int y,int b,int f)
{
	if((getpixel(x,y)!=b) && (getpixel(x,y)!=f))
	{
		putpixel(x,y,f);
		boundfill(x+1,y,b,f);
		boundfill(x-1,y,b,f);
		boundfill(x,y-1,b,f);
		boundfill(x,y+1,b,f);
	}
}